import java.util.Scanner;

/**
 * 键盘数据 形成空心正方形
 */
public class KongXinZhengFangXing {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("清输入正方形边长:");
            int n = sc.nextInt();
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    if (i == 1 || i == n){
                        System.out.print("*");
                    } else if (j == 1 || j == n){
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.println(" ");
            }
        }
    }
}
